/*-----------------------------------------------------------------------------
 * @file   perf.h
 * @brief  Performance measuring tools.
 * @author WLH<wanglehui8357@163.com> Copyright (C) 2021~2099.
----------------------------------------------------------------------------*/
#ifndef PERF_H
#define PERF_H

#include "hal_hrt.h"

BEGIN_DECLS

typedef struct
{
    hrt_abstime start;  /* unit: us    */
    U32 duration;       /* max:  71min */
} perf_t;

#define PERF_START(p)  do { (p).start    = hal_hrt_get_us(); } while(0)
#define PERF_STOP(p)   do { (p).duration = (U32)(hal_hrt_get_us() - (p).start); \
                            (p).start    = hal_hrt_get_us();} while(0)

END_DECLS

#endif//~PERF_H
